package com.android.stm;

import org.anddev.andengine.entity.primitive.Rectangle;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.Scene.IOnSceneTouchListener;
import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.entity.shape.Shape;
import org.anddev.andengine.entity.text.Text;
import org.anddev.andengine.input.touch.TouchEvent;
import org.anddev.andengine.util.HorizontalAlign;
import org.apache.http.params.CoreConnectionPNames;

import android.app.Activity;
import android.content.Intent;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.Toast;

public class SceneManager extends Activity {
	 
	private MultiScreen base;
	
	private MenuScrollerActivity game;
	
	private SaveTheMageActivity svtm;
	
	protected boolean isGame = false;
	
	public Scene sceneSM;
	public Scene sceneBack;
	
	public Shape ground;
 
	public SceneManager(MultiScreen base) {
		this.base = base;
	}
	
	public SceneManager(SaveTheMageActivity base) {
		this.svtm = base;
	}
	
	public SceneManager(MenuScrollerActivity game) {
		this.game = game;
	}
 
	public void loadMain() {
		
		isGame = false;

		final Scene scene = new Scene();
		scene.setBackground(new ColorBackground(0.9804f, 0.2274f, 0.4784f));
 
        final Text textCenter = new Text(100, 60, base.mFont, "hello plop", HorizontalAlign.CENTER);
        scene.attachChild(textCenter);
        base.getEngine().setScene(scene);
	}
	
	
	public void loadGame() {
		
		isGame = true;
	
		final Scene scene = new Scene();
		scene.setBackground(new ColorBackground(0.9804f, 0.2274f, 0.4784f));
 
	      
        final Text textCenter = new Text(100, 60, game.mFont, "GAME", HorizontalAlign.CENTER);
        scene.attachChild(textCenter);
 
	       
        game.getEngine().setScene(scene);
        
      

        
	}
	
public void loadMenu() {
		
		final Scene scene = game.getEngine().getScene();
		
		scene.setBackground(new ColorBackground(0.1804f, 0.7274f, 0.4784f));
		
		//Toast.makeText(this, ""+scene.getScaleX(), Toast.LENGTH_LONG).show();
		//Log.d("X", "X: ");
		
		//DisplayMetrics metrics = new DisplayMetrics();
		//getWindowManager().getDefaultDisplay().getMetrics(metrics);

		
		//final Shape ground = new Rectangle(0, 0, metrics.widthPixels,metrics.heightPixels);
		final Shape ground = new Rectangle(0, 0, 400, 800);
		
		ground.setColor(0.1804f, 0.6274f, 0.8784f,0.8f);
		
		scene.attachChild(ground);
		
		
		
		game.getEngine().setScene(scene);
		
	}

public void Reset() {
	
	final Scene scene = svtm.getEngine().getScene();
	
	
	
	game.getEngine().setScene(scene);
	
}


public void loadMenuInGame() {
	
	sceneSM = svtm.getEngine().getScene();
	
	
	 ground = new Rectangle(0, 0, 500, 1200);
	
	ground.setColor(0.1804f, 0.6274f, 0.8784f, 0.8f);
	
	/*final Shape back = new Rectangle(30, 30, 40, 80);
	
	back.setColor(0.1804f, 0.2274f, 0.2784f);
		
	
	 scene.setOnSceneTouchListener(new IOnSceneTouchListener() {
         
         public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
            
             if(pSceneTouchEvent.getX() > back.getX() && pSceneTouchEvent.getX() < (back.getX() + back.getWidth()) &&
                pSceneTouchEvent.getY() > back.getY() && pSceneTouchEvent.getY() < (back.getY() + back.getHeight()) )
             {
            	 back.setColor(1, 1, 1);
          
             }
        	 
        	 
                 return true;
         }
         
      
	 	});
	
	
	 scene.attachChild(back);
	
	*/
	
	sceneSM.attachChild(ground);
	
	svtm.getEngine().setScene(sceneSM);
	
}
	  
	
	public void loadMage() {
		
		final SaveTheMageActivity stm = new SaveTheMageActivity();
		
		
		
	}
}